package com.itheima.mapper;

import com.itheima.pojo.Clazz;
import com.itheima.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {
    // 查询所有班级
    @Select("select c.*,e.name masterName from clazz c left join emp e on c.master_id = e.id")
    List<Clazz> getAll();
    // 添加班级
    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject) " +
            "values(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject})")
    void addClass(Clazz clazz);
    // 删除班级
    @Delete("delete from clazz where id=#{id}")
    void deleteClass(Integer id);
    // 根据id查询班级
    @Select("select * from clazz where id=#{id}")
    Clazz getById(Integer id);
    // 修改班级
    @Update("update clazz set name = #{name},room = #{room},begin_date = #{beginDate},end_date = #{endDate},master_id = #{masterId},subject = #{subject},update_time=#{updateTime} where id = #{id}")
    void putClass(Clazz clazz);
    // 分页查询班级
//    @Select("select c.*,e.name masterName from clazz c left join emp e on c.master_id = e.id")
    List<Clazz> list(ClazzQueryParam param);
}

